<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>发布报告/资料</title>
    <meta name="keywords" content=""/>
    <meta name="description" content=""/>
    <meta http-equiv="X-UA-Compatible" content="IE=7"/>
    <link href="css/common.css" type="text/css" rel="stylesheet"/>
    <link href="css/upload_group.css" type="text/css" rel="stylesheet"/>
    <link href="css/upload_group_con.css" type="text/css" rel="stylesheet"/>
    <link href="css/thickbox.css" type="text/css" rel="stylesheet"/>
    <script src="https://cdn.bootcss.com/jquery/3.4.1/jquery.min.js"></script>
    <script src="./js/common.js" type="text/javascript"></script>
    <script src="./js/my_download.js" type="text/javascript"></script>
    <script type="text/javascript" src="js/thickbox.js"></script>
    <link href="css/top.css" rel="stylesheet" type="text/css"/>
    <link href="css/bbs_index_new.css" rel="stylesheet" type="text/css"/>
    <link href="css/master.css" rel="stylesheet" type="text/css"/>
    <link rel="stylesheet" type="text/css" href="css/newtheme.css">
    <script src="js/pc_client.js" type="text/javascript"></script>
    <link type="text/css" rel="stylesheet" href="css/zl_header.css"/>
    <link type="text/css" rel="stylesheet" href="layui/css/layui.css"/>
    <script src="layui/layui.all.js" type="text/javascript"></script>
    <script src="https://cdn.bootcss.com/layer/2.3/layer.js"></script>
    <link href="https://cdn.bootcss.com/layer/2.3/skin/layer.css" rel="stylesheet">
    <script src="https://cdn.bootcss.com/wangEditor/10.0.13/wangEditor.min.js"></script>
</head>

<body>
<div class="top clientHidden">
    <div class="top-content clearfix">
        <!-- logo -->
        <a class="zl-logo" href="index.html" title="首页"></a>
        <div class="top-navbar clearfix">
            <!-- left  -->
            <ul class="left-bar" id="hid">
                <li style="position:relative;filter: inherit;z-index:10000">
                    <a href="javascript:;" id="more">报告/资料&nbsp;<b class="j-bottom"></b></a>
                    <div id="detail" class="more-div clearfix">
                    </div>
                </li>
                <li class="zl-nav">
                    <div class="fornav-active"></div>
                    <a href="/v2/article_list.html" rel="nofollow" target="_blank" title="行业动态">行业动态</a>
                </li>
            </ul>
            <!-- right -->
            <ul class="zhul_tpright1 right-bar" id="zhul_header_nav1">
                <li id="my" class="user-info is-login" style="z-index: 10000; display: inline;">
                    <a id="username" href="">个人中心<b
                            style="margin-left:5px;" class="j-bottom"></b></a>
                    <div id="user-menu" class="user-menu clearfix" style="display: none;">
                        <i class="j-top"></i>
                        <a href="my_upload.html" target="_blank">我的上传</a>
                        <a href="my_download.html">我的下载</a>
                        <p class="line"></p>
                        <a href="my_account.html" target="_blank">我的账户</a>
                        <p class="line"></p>
                        <a href="javascript:;" id="user-logout">退出登录</a>
                    </div>
                </li>
                <li><a class="youse is-login" href="">我要上传</a></li>
                <li><a class="youse unlogin" href="javascript:;" id="login">登录/注册</a></li>
            </ul>
            <!-- 搜索 -->
            <div class="search-box" id="search-box">
                <div class="s-content" id="search">
                    <form method="GET" name="q_search" onsubmit="return false;">
                        <input id="search-input" type="text" name="q" class="search-input" autocomplete="off"
                               onfocus="value='';this.style.color='#000000';" value="">
                        <input id="searchKeywords" type="hidden" value="">
                    </form>
                    <a href="javascript:void(0)" id="sou" class="search-btn"></a>
                    <a href="javascript:void(0)" id="sousuo" class="search-btn2" style="display: none;"></a>
                </div>
            </div>
        </div>

    </div>
</div>
<script type="text/javascript">
    var low_IE = false;
</script>
<!--[if IE 9]>
<script type="text/javascript">low_IE = true;</script> <![endif]-->
<!--[if IE 8]>
<script type="text/javascript">low_IE = true;</script> <![endif]-->
<!--[if gte IE 7]>
<script type="text/javascript">low_IE = true;</script><![endif]-->
<script type="text/javascript" src="js/zlhead.js"></script>
<div class="edu-topbanner">
    <div class="topbanner-bg">
    </div>
    <div class="topbanner-text clearfix">
        <div class="f-l">
            <a href="javascript:;" class="f-size18 f-l" style="*display: inline-block;">
                <span style="float: left;font-size: 18px;color: #ddd">发布报告/资料</span>
            </a>
        </div>
    </div>
</div>
<script type="text/javascript">
    // 头部固定导航条
    var boxLeft = $("#search-box").offset().left - $(document.body).width() / 2 + 219;
    $(document).ready(function () {
        $(window).resize(function () {
            changeFixEle();
        });
        $(window).scroll(function () {
            changeFixEle();
        });
    });

    function changeFixEle() {
        return;
        var scrolltop = document.documentElement.scrollTop || document.body.scrollTop;
        if ($("#side-right").length > 0) {
            var offseRight = $(document.body).width() - ($("#side-right").offset().left);
        } else {
            var offseRight = $(document.body).width() / 2 - boxLeft;
        }
        ;
        if (scrolltop >= 40) {
            $("#search-box").addClass('fixed-nav').css("right", offseRight + 'px');
            $(".edu-topbanner").css({
                'position': 'fixed',
                'top': 0,
                'width': '100%'
            });
            $('.zhul_footer').css('padding-bottom', '50px');
            $("#e-con").css('margin-top', '60px');
        } else {
            $(".edu-topbanner").css({
                'position': '',
                'top': 0
            });
            $("#e-con").css('margin-top', '10px');
            $("#search-box").removeClass('fixed-nav').removeAttr('style');
        }
    }
</script><!--main部分-->
<div class="zhul_main_warpper">
    <div class="zhul_nwarp_ncon" style="">
        <div class="zhul_nmain_con" style="">
            <div class="zhul_nft_top">
                <p class="zhul_ft_ltit">发布</p>
            </div>


            <form class="layui-form" id="resourceForm">
                <div class="layui-form-item">
                    <label class="layui-form-label"><span style="color: red">*</span>资源名称</label>
                    <div class="layui-input-block">
                        <input type="text" name="resourceName" required lay-verify="required" lay-verType="tips" placeholder="请输入资源名称"
                               autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">资源简介</label>
                    <div class="layui-input-block">
                        <input type="text" name="resourceIntroduction" placeholder="请输入资源简介" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label"><span style="color: red">*</span>资源积分</label>
                    <div class="layui-input-block">
                        <input type="number" name="resourcePrice" required lay-verify="required" lay-verType="tips"  placeholder="1元=10积分"
                               autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label"><span style="color: red">*</span>资源类型</label>
                    <div class="layui-input-block">
                        <select name="resourceTypeId" required lay-verify="required" lay-verType="tips" >
                            <option value=""></option>
                        </select>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">资源封面</label>
                    <div class="layui-input-block">
                        <input type="file" name="coverImage" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label"><span style="color: red">*</span>资源文件</label>
                    <div class="layui-input-block">
                        <input type="file" name="resourceFile" required lay-verify="required" lay-verType="tips" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item layui-form-text">
                    <label class="layui-form-label">资源详情</label>
                    <div class="layui-input-block">
                        <div id="editor-area" name="content"
                             style="border: 1px solid #ccc;min-height:300px;width: 100%;"></div>
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-input-block">
                        <button class="layui-btn" type="button" lay-submit id="uploadForm" lay-filter="formDemo">上传
                        </button>
                    </div>
                </div>
            </form>

        </div>
    </div>
</div>

<!--footer部分-->
<div class="zhul_footer clientHidden">
    <div class="zhul_bot_footer">
        <p>
            <a href="about_us.html" class="zhul_botmenu_link" target="_blank">关于我们</a>
            <a href="contac_us.html" class="zhul_botmenu_link" target="_blank">联系我们</a>
            <a href="agreement.html" class="zhul_botmenu_link" target="_blank">用户使用协议及免责声明</a>
        </p>
        <p><span class="zhul_botmenu_font">尽智研究院</span>
            <a href="http://beian.miit.gov.cn/" style="color: #666">
                京<span class="zhul_botmenu_font">ICP</span>证<span class="zhul_botmenu_font">19011090</span>号-1</a>
        </p>
        <p>通信地址：北京市朝阳区<span class="zhul_botmenu_font">（100020）</span></p>
    </div>
</div>
<div style="display:none;">

    <script>
        //加载css
        function zhul_addcss(url) {
            var script = document.createElement('link');
            script.setAttribute('type', 'text/css');
            script.setAttribute('href', url);
            script.setAttribute('rel', 'stylesheet');
            document.body.appendChild(script);
        }

        //加载js
        function zhul_addjs(url, callback) {
            var script = document.createElement('script');
            script.setAttribute('type', 'text/javascript');
            script.setAttribute('src', url);
            script.onload = script.onreadystatechange = function () {
                if (!this.readyState || this.readyState == 'loaded' || this.readyState == 'complete') {
                    if (typeof callback == "function") {
                        callback();
                    }
                }
            };
            document.body.appendChild(script);
        }
    </script>


    <script type="text/javascript" src="https://s4.cnzz.com/z_stat.php?id=1633628&web_id=1633628"></script>
    <script type="text/javascript" src="https://s4.cnzz.com/z_stat.php?id=5078536&web_id=5078536"></script>

    <script src="https://c.zhulong.com/cno.js"></script>


</div>
<!--<script type="text/javascript" src="js/zl_top.js"></script>-->
<script>
    var BASE_URL = 'http://jinzhidata.com/v2'

    var E = window.wangEditor
    var editor = new E("#editor-area");
    editor.customConfig.customUploadImg = function (files, insert) {
        // files 是 input 中选中的文件列表
        // 注意这里 files 中的第 0 个元素才是当前上传的文件对象
        // insert 是获取图片 url 后，插入到编辑器的方法
        var formData = new FormData();
        formData.append("file", files[0]);
        $.ajax({
            type: "POST",
            url: BASE_URL + "/editor/image", //接口请求地址
            dataType: 'JSON',
            contentType: false,
            processData: false,
            data: formData,
            success: function (res) {
                if (res.code === 0) {
                    console.log('上传图片成功')
                    insert(res.data.src)
                } else {
                    layer.msg(res.msg, {icon: 5});
                }
            }
        })
    }
    editor.create()
    layui.use(['form', 'layedit'], function () {
        var $ = layui.$
        var form = layui.form;
        var layedit = layui.layedit;

        form.render()


        function uploadResource() {
            console.log('上传')
            var formData = new FormData(document.getElementById("resourceForm"))
            // var requiredField = ['resourceName', 'resourcePrice', 'resourceTypeId']
            // for (var i = 0; i < requiredField.length; i++) {
            //     if (!formData.get(requiredField[i])) {
            //         return
            //     }
            // }
            if (!formData.get('resourceFile').name) {
                return
            }
            var loading = layer.load(1, {
                shade: [0.1, '#fff'],
            });
            formData.append("resourceDetail", editor.txt.html())
            $.ajax({
                type: "post",
                url: BASE_URL + "/resource",
                data: formData,
                contentType: false,
                processData: false,
                success: function (response) {
                    layer.close(loading);
                    if (response.code === 0) {
                        layer.msg('上传成功', function () {
                            window.location.reload()
                        })
                    } else if (response.code === 1001) {
                        layer.msg('您还没有登录！', {icon: 2}, function () {
                            login()
                        })
                    } else {
                        layer.msg(response.msg, {icon: 5});
                    }
                }
            })
        }

        // form.verify({
        //     img: function (value) {
        //         var formData = new FormData(document.getElementById("resourceForm"))
        //         var coverImageName = formData.get('coverImage').name
        //         console.log(coverImageName)
        //         if (coverImageName && !/.(jpeg|jpg|png)$/.test(coverImageName)) {
        //             return "资源封面图片类型必须是jpeg,jpg,png中的一种";
        //         }
        //     }
        // })

        // 监听提交
        form.on('submit(formDemo)', function (data) {
            uploadResource()
            return false;
        });

        $(function () {
            // layedit.set({
            //     uploadImage: {
            //         url: BASE_URL + '/editor/image', //接口url
            //         type: 'POST' //默认post
            //     }
            // });
            // editorIndex = layedit.build('edit-area'); //建立编辑器


            // 加载分类
            $.ajax({
                url: BASE_URL + "/resource/type/list",
                type: "get",
                contentType: 'application/json',
                dataType: "json",
                success: function (response) {
                    var data = response.data
                    for (var i = 0; i < data.length; i++) {
                        var resourceTypeId = data[i].resourceTypeId
                        var resourceTypeName = data[i].resourceTypeName
                        $("select[name='resourceTypeId']").append('<option value="' + resourceTypeId + '">' + resourceTypeName + '</option>')
                    }
                    var form = layui.form;
                    form.render()
                }
            })
        })


    });


</script>
<!-- 统计代码 -->
</body>
</html>
